package com.net.xpay.stable;

import com.net.common.web.SpringContextHolder;
import com.net.xpay.core.CoreConfiguration;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 把一些需要长时间稳定运行的服务方在这个模块 一般不会重启
 */
@SpringBootApplication
@EnableScheduling
@Import({CoreConfiguration.class})
@ComponentScan(basePackages = {"com.net.xpay", "com.net.noah"})
public class StableMain {

    public static void main(String[] args) {
        SpringApplication.run(StableMain.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {
            SpringContextHolder.setSpringContext(ctx);
            ctx.getBean(JobEntry.class).start();
        };
    }

}
